
import 'package:date_format/date_format.dart';
import 'package:url_launcher/url_launcher.dart';

import 'toast.dart';

///常用工具类
class Utils {
  Utils._internal();

  //=============url_launcher==================//

  ///处理链接
  static void launchURL(String url) async {
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      ToastUtils.error("暂不能处理这条链接:$url");
    }
  }

  //=============package_info==================//

  // ///获取应用包信息
  // static Future<PackageInfo> getPackageInfo() {
  //   return PackageInfo.fromPlatform();
  // }
  //
  // ///获取应用包信息
  // static Future<Map<String, dynamic>> getPackageInfoMap() async {
  //   PackageInfo packageInfo = await PackageInfo.fromPlatform();
  //   return <String, dynamic>{
  //     'appName': packageInfo.appName,
  //     'packageName': packageInfo.packageName,
  //     'version': packageInfo.version,
  //     'buildNumber': packageInfo.buildNumber,
  //   };
  // }

  //=============date_format==================//

  static String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();

  static String formatDateTime(DateTime dateTime) =>
      formatDate(dateTime, [yyyy, '-', mm, '-', dd]);

}
